package com.erp.servlet;

import com.erp.bean.OrderState;
import com.erp.service.OrderService;
import com.erp.service.OrderStateService;
import com.erp.service.impl.OrderServiceImpl;
import com.erp.service.impl.OrderStateServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @author mtf
 * 查询订单状态列表控制器
 */
@WebServlet("/statelist.action")
public class OrderStateListServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //创建逻辑对象
        OrderStateService orderStateService = new OrderStateServiceImpl();
        //将查询到的对象放入集合中
        List<OrderState> list = orderStateService.findAll();
        //放入作用域
        req.setAttribute("list",list);
        //转发到订单状态列表
        req.getRequestDispatcher("orderstatelist.jsp").forward(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
